home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Source Code / Visual Basic Source Code.iso / vbsource / visds / modaldlg.dsc < prev    next >
Text File  |  1999-05-02  |  2KB  |  62 lines

  1.     title Modal Dialog Test
  2. REM Demonstrate creating and using a modal child dialog
  3.   DIALOG CREATE,Main Dialog,20,20,220,166,SAVEPOS Main
  4.   DIALOG ADD,LIST,LIST1,10,10,198,96
  5.     DIALOG ADD,BUTTON,Add,116,10,,,,default
  6.   DIALOG ADD,BUTTON,Close,116,144,64,24
  7.   DIALOG ADD,STATUS,SB,Click Add to add an item of text to the list
  8.   DIALOG SHOW
  9.     
  10. :Main_evloop
  11.     wait event
  12.     %E = @event()
  13.     goto %E
  14.  
  15. :AddBUTTON
  16.     goto Child_Dialog
  17.  
  18. :CloseBUTTON
  19. :CLOSE
  20.     exit
  21.  
  22. :Child_Dialog
  23.   DIALOG CREATE,Child Dialog,20,0,284,72,SAVEPOS Child,NOMIN
  24.     DIALOG ADD,EDIT,CEDIT1,10,10
  25.     DIALOG ADD,BUTTON,OK,8,206,,,,default
  26.     DIALOG ADD,BUTTON,Cancel,38,206
  27.   DIALOG SHOWMODAL
  28.     
  29. REM When SHOWMODAL is used, only the buttons on the child
  30. REM dialog can generate an event. This simplifies the
  31. REM event processing compared to the non-modal example,
  32. REM no event loop is needed or indeed possible, because
  33. REM once any button is pressed the dialog is closed. This
  34. REM means that all you can do is get the data from the
  35. REM child dialog (depending on what button was pressed)
  36. REM and then close the form.
  37.     
  38.     wait event
  39.     %E = @event()
  40. REM The modal dialog has disappeared from the screen, although
  41. REM it still exists so you can get the data from it.
  42.     goto Child_%E
  43.  
  44. :Child_OKBUTTON
  45.     dialog select,1
  46.     %A = @dlgtext(cedit1)
  47.     dialog select,0
  48.     list add,list1,%A
  49.     dialog select,1
  50.     
  51. :Child_CancelBUTTON
  52. :Child_CLOSE
  53. REM This DIALOG CLOSE command closes the (now hidden)
  54. REM dialog
  55.     DIALOG CLOSE
  56. REM Wait for the CLOSE event that is generated...
  57.     wait event
  58. REM ...and throw it away (otherwise it will be executed
  59. REM by the main event loop!)
  60.     %E = @event()
  61.     goto Main_evloop
  62.